package com.own.business.exam.entity.dto;


import com.own.business.exam.entity.bo.ExamPaperBo;
import com.own.component.common.base.entity.BaseDto;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * ExamPaperDto
 *
 * @author 陈学礼 （你是一段成熟的代码，要学会自己改bug）
 * @version 4.0.0
 * @date 2021/05/18 14:43:47
 * @since 4.0.0
 */
@ApiModel("考试试卷表" + ConstantBeanSuffix.DTO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class ExamPaperDto extends BaseDto<ExamPaperBo> {

    @ApiModelProperty("试卷id")
    private Long examId;

    @ApiModelProperty("用户id")
    private Long userId;

    @ApiModelProperty("规则id")
    private Long ruleId;

    @ApiModelProperty("练习id")
    private Long practiceId;

    @ApiModelProperty("题目数量")
    private Integer questionNumber;

    @ApiModelProperty("作答状态 0=未作答 1=已作答 2=保存 3=废弃")
    private Integer status;

    @ApiModelProperty("用时（ms）")
    private Long useTime;

    @ApiModelProperty("分数")
    private BigDecimal score;

    @ApiModelProperty("提交练习的时间")
    private LocalDateTime submitTime;

    /**
     * 转业务层对象
     *
     * @param entity 原业务层对象
     * @return 业务层对象
     */
    @Override
    public ExamPaperBo toBo(ExamPaperBo entity) {
        if (entity == null) {
            entity = new ExamPaperBo();
        }
        entity.setExamId(examId);
        entity.setUserId(userId);
        entity.setRuleId(ruleId);
        entity.setPracticeId(practiceId);
        entity.setQuestionNumber(questionNumber);
        entity.setStatus(status);
        entity.setUseTime(useTime);
        entity.setScore(score);
        entity.setSubmitTime(submitTime);
        return super.toBo(entity);
    }

}
